home *** CD-ROM | disk | FTP | other *** search
/ GFX Sensations 1 / Graphic Sensations - Volume 1.iso / tools / amiga / 3d_tools / rend10.lzh / REND1.0 / GraphicSubSystem / raster.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  2.9 KB  |  108 lines

  1. /*
  2.  * Title:
  3.  *    raster.c
  4.  *
  5.  * Authors:
  6.  *    Michael P. Schenck
  7.  *
  8.  * Purpose:
  9.  *    This module handles the output of the raster list constructed in
  10.  *    the viewing and perspective transformation (viewperstrans.c) module.
  11.  *      The scanconvert routine moves through the raster list and draws all
  12.  *    the polygons described.  It uses the linemap for each object
  13.  *    (see database.c) to determine shared edges and not draw those 
  14.  *    lines.
  15.  *
  16.  * Copyright Info:
  17.  *    Copyright (C) 1993, 1994 -- by Michael P. Schenck, 
  18.  *    (mps4466@ultb.isc.rit.edu)
  19.  *    
  20.  *    This program is free software; you can redistribute it and/or modify
  21.  *    it under the terms of the GNU General Public License as published
  22.  *    by the Free Software Foundation; either version 2 of the License,
  23.  *    or (at your option) any later version.
  24.  *
  25.  *    This software is distributed in the hope that it will be useful, but
  26.  *    WITHOUT ANY WARRANTY; without even the implied warranty of
  27.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  28.  *    GNU General Public License for more details.
  29.  *
  30.  *      For a copy of the GNU General Public License
  31.  *    write to the Free Software Foundation, 675 Mass Ave,
  32.  *    Cambridge, MA  02139, USA.
  33.  *
  34.  */
  35.  
  36. #include <stdlib.h>
  37. #include <math.h>
  38. #include <exec/types.h>
  39. #include <exec/memory.h>
  40. #include <proto/exec.h>
  41. #include <proto/intuition.h>
  42. #include <proto/graphics.h>
  43. #include "/include/errors.h"
  44. #include "/include/display.h"
  45. #include "/include/viewperstrans.h"
  46. #include "/include/matrix.h"
  47. #include "/include/database.h"
  48. #include "/include/raster.h"
  49.  
  50. extern struct Object *objects[MAXNUMOBJECTS];
  51. extern ULONG objectviewlist[MAXPOLYINVIEW],
  52.              polyviewlist[MAXPOLYINVIEW],
  53.          viewlistindex;
  54. extern UWORD height;
  55.  
  56.     /* Scan convert (wireframe) all polys in the viewlist. */
  57.     
  58. void scanconvert()
  59. {    
  60.    
  61.    register WORD x0,y0,x1,y1,x2,y2;
  62.    register ULONG i,j,offset,curpoly,curvert;
  63.    WORD x,y;
  64.    ULONG *polygons,curobject=NOOBJECT;
  65.    FLOAT *transvert;
  66.    UBYTE *edgeshare;    
  67.       
  68.    for(i=0;i<viewlistindex;i++) {   
  69.  
  70.       if(curobject != objectviewlist[i]) {
  71.          curobject = objectviewlist[i];
  72.          polygons = objects[curobject]->polygons;
  73.          transvert = objects[curobject]->transvert;
  74.          edgeshare = objects[curobject]->edgeshare;
  75.       }
  76.      
  77.       curpoly = polyviewlist[i]*MAXPOLYVERT;
  78.       curvert = *(polygons+curpoly);
  79.       x = (WORD)*(transvert+curvert*4); 
  80.       y = height - (WORD)*(transvert+curvert*4+1);
  81.       x2 = x;
  82.       y2 = y;
  83.       
  84.       for(j=1;j<(MAXPOLYVERT-1);j++) {
  85.      offset = j;
  86.      if((curvert = *(polygons+curpoly+j))==NOVERT) {
  87.         j=MAXPOLYVERT-1;
  88.         x1 = x;
  89.         y1 = y;
  90.      }
  91.      else {
  92.         x1 = (WORD)*(transvert+curvert*4);
  93.         y1 = height - (WORD)*(transvert+curvert*4+1);    
  94.      }
  95.     
  96.      x0 = x2;
  97.      y0 = y2;
  98.      x2 = x1;
  99.      y2 = y1;
  100.      
  101.          /* Draw line if not already drawn. */ 
  102.  
  103.      if(*(edgeshare+curpoly+offset-1)) 
  104.         line(x0,y0,x1,y1);       
  105.       }
  106.    }
  107. }   
  108.